package com.chaoyong.higo.adapter;

import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chaoyong.higo.R;
import com.chaoyong.higo.base.BaseAdapter;
import com.chaoyong.higo.utils.ViewHolder;

public class RecomAdapter extends BaseAdapter<Object> {
	private String[] itemsName = { "价值（由高到低）", "价值（由低到高）", "最新" };

	public RecomAdapter(Context context) {
		super(context);
	}

	private TextView item_recom_tx;
	private LinearLayout item_recom_lay;
	private SetHoldOnClinck clinck;
	private SetHoldOnClinck onClinck;

	@Override
	public int getCount() {
		return itemsName.length;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.item_recom, null);
		}
		item_recom_tx = ViewHolder.get(convertView, R.id.item_recom_tx);
		item_recom_lay = ViewHolder.get(convertView, R.id.item_recom_lay);
		item_recom_tx.setText(itemsName[position]);
		item_recom_tx.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (onClinck != null) {
					onClinck.onclick(position);
				}
			}
		});
		return convertView;
	}

	public void setOnHolderClickListener(SetHoldOnClinck onClinck) {
		this.onClinck = onClinck;
	}

	public interface SetHoldOnClinck {
		void onclick(int position);
	}

}
